home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
basic
/
qbnws104.zip
/
IQUEUE.ZIP
/
STACKS.BAS
< prev
Wrap
BASIC Source File
|
1990-07-18
|
2KB
|
52 lines
DEFINT A-Z
' A demo program which shows the use of the Stack and Queue
' routines discussed in "Improving Your IQUEUE". The source
' for the MASM functions is in the .ASM files.
'
' The following routines are all in STAQUE.LIB, which you can make into
' a QLB file by...
' LINK /q staque,,nul,bqlb45; (or whatever LIB you need)
DECLARE SUB IQPut (intval%) 'put an item in the queue
DECLARE FUNCTION IQget% () 'get an item from the queue
DECLARE FUNCTION IQfree% () 'TRUE if any room in queue
DECLARE FUNCTION IQavail% () 'TRUE if anything in queue
DECLARE SUB IQflush () 'clear (empty) the queue
DECLARE SUB ISPush (ival%) 'put an item on the stack
DECLARE FUNCTION ISpop% () 'get an item off the stack
DECLARE FUNCTION ISfree% () 'TRUE if any room on stack
DECLARE FUNCTION ISavail% () 'TRUE if anything on stack
DECLARE SUB ISClear () 'clear the stack
CLS
k = 0
DO WHILE IQfree 'while any room in queue
k = k + 1 'put a different item
IQPut k 'into each queue slot
LOOP
PRINT k; "items originally enqueued"
FOR j = 1 TO 99 'now take out some items
k = IQget 'and throw them away
NEXT
PRINT j - 1; " items dequeued"
k = 0
DO WHILE IQfree 'now put items again until full
k = k + 1
IQPut k
LOOP
PRINT k; "additional items enqueued"
k = 0
DO WHILE ISfree AND IQavail 'while room on stack and data in queue
k = k + 1 'count items
ISPush IQget 'move from queue to stack
LOOP
PRINT k; "items dequeued and pushed"
PRINT " Popping all items now"
DO WHILE ISavail 'now pop items while any remain
PRINT ISpop;
LOOP
PRINT